package com.tanhua.server.service;


import com.tanhua.dubbo.api.UserInfoApi;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.vo.UserInfoVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class UserInfoService {

    @DubboReference
    private UserInfoApi userInfoApi; 


    public void save(UserInfo userInfo) {
        userInfoApi.save(userInfo);
    }

    public void update(UserInfo userInfo) {
        userInfoApi.update(userInfo);
    }

    public UserInfoVo findById(Long useID) {
        //通过id,查询到数据库里面此id的信息
        UserInfo userInfo = userInfoApi.findById(useID);

        UserInfoVo Vo = new UserInfoVo();
        BeanUtils.copyProperties(userInfo,Vo); //copy同名同类型的属性
        if (userInfo.getAge() != null){
            Vo.setAge(userInfo.getAge().toString());
        }
        return Vo;
    }
}
